/*
 ConcurrentListContainer is an auxilary class for Michael-Scott queue. It inherits from TaskContainer.
 */
#ifndef CONCURRENTLISTCONTAINER_H_
#define CONCURRENTLISTCONTAINER_H_
#include "MSQueue.hpp"
#include "TaskContainer.h"
#include "Config.h"

class ConcurrentListContainer:public TaskContainer{
	MSQueue<Task*> *Q;
public:
	ConcurrentListContainer(){Q = new MSQueue<Task*>();}
	
	virtual ~ConcurrentListContainer(){
		Task* t;
		Statistics* dummy_stat = new Statistics();
		while(Q->dequeue(t,dummy_stat))
		{
			delete t;
		}
		delete dummy_stat;
		delete Q;
	}

	void put(Task* task,Statistics* stat){Q->enqueue(task,stat);}

	Task* get(Statistics* stat){
		Task* t = NULL;
		if(Q->dequeue(t,stat))
		{
			return t;
		}
		return NULL;
	}

	//void setConsumersNum(int consumersNum){}
	void registerConsumer(int tid){}
	void registerProducer(int tid){}
	void init(){}
	//int getDebugInfo(){return 0;}
};

#endif /* CONCURRENTLISTCONTAINER_H_ */
